package sort.basic;

import java.util.Arrays;

public class insertSort {
	
	private static Integer[] nums={34,78,90,45,3432,343,43,545,464,57,23,1323};
	
	public static <AnyType extends Comparable< ? super AnyType>>
	AnyType[] insertSortOnce(AnyType[] num){
		AnyType[] arr = num;
		for (int p =1 ;p < arr.length ;p++){
			AnyType tmp = arr[p];
			int j =p;
			for( ;j >0 && tmp.compareTo(arr[j-1]) <0 ;j--){
				arr[j] = arr[j-1];
			}
			arr[j] = tmp;
		}
		return arr;
	}
	
	public static void main(String[] args){
		println(Arrays.toString(insertSortOnce(nums)));
		println(Arrays.toString(nums));
	}
	
	private static void println(String str){
		System.out.println(str);
	}
}
